package sample1;
import lovedna.events.Event;
import lovedna.game.Actor;
import lovedna.game.Material;
import lovedna.game.Shader;
import lovedna.game.ShaderCode;
import lovedna.game.components.G3D;
import lovedna.game.components.MeshRenderer;
import lovedna.game.graphics.GLState;
import lovedna.resource.Assets;
import lovedna.utils.macro.CompileTime;


/**
 * ... 
 * @author liwei
 */
class XRayEff extends Actor
{
	/*======constants============================*/
	
	/*======static ==============================*/
	
	/*======Public===============================*/
	
	/*======Private==============================*/
	private var g3d:G3D;
	private var _shader:Shader;
	private var _code:ShaderCode;
	public function new() 
	{
		super();
		
		//Client.instance.camera.actor.addComponent(lovedna.game.components.CameraControl);
		
		var vert:String =CompileTime.readFile("src/sample1/xray_vert.txt");
		var frag:String = CompileTime.readFile("src/sample1/xray_frag.txt");
		_code = new ShaderCode("", vert, frag);
		var actor:Actor = new Actor();
		actor.setParent(this);
		g3d = actor.addComponent(G3D);
		g3d.resource = Assets.g3d.get("g3d/chr_man.g3d");
		g3d.addEventListener(Event.init.type, ong3dInit);
	}
	
	
	/*======Public Static methods================*/
	
	/*======Public methods=======================*/
	
	/*======public override methods==============*/
	
	/*======private override methods=============*/
	function ong3dInit(?e):Void 
	{
		trace(g3d.rendererCount);
		var len:Int = g3d.rendererCount;
		while (len-- > 0)
		{
			//var mat:Material = g3d.getRenderer(len).material;
			//mat.shader.setCode(_code);
			//mat.state.cullMode = GLState.CULLMODE_FRONT;
			//mat.state.depthWrite = false;
		}
		//Client.instance.mapWorld.addChild(new SkyMap());
	}
	/*======Private methods======================*/
	
	/*======get set methods======================*/
	
}